package com.ltkj.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ltkj.shop.domain.vo.ShopHotelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopHotel;
import com.ltkj.shop.service.IShopHotelService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 酒店商户Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "酒店商户")
@RestController
@RequestMapping("/hotel")
public class ShopHotelController extends BaseController
{
    @Autowired
    private IShopHotelService shopHotelService;

    /**
     * 查询酒店商户列表
     */
    @ApiOperation("查询酒店商户列表")
    @RequiresPermissions("shop:hotel:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopHotel shopHotel)
    {
        startPage();
        List<ShopHotelVo> list = shopHotelService.selectShopHotelList(shopHotel);
        return getDataTable(list);
    }

    /**
     * 导出酒店商户列表
     */
    @ApiOperation("导出酒店商户列表")
    @RequiresPermissions("shop:hotel:export")
    @Log(title = "酒店商户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopHotel shopHotel)
    {
        List<ShopHotelVo> list = shopHotelService.selectShopHotelList(shopHotel);
        ExcelUtil<ShopHotelVo> util = new ExcelUtil<ShopHotelVo>(ShopHotelVo.class);
        util.exportExcel(response, list, "酒店商户数据");
    }

    /**
     * 获取酒店商户详细信息
     */
    @ApiOperation("获取酒店商户详细信息")
    @RequiresPermissions("shop:hotel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopHotelService.selectShopHotelById(id));
    }

    /**
     * 新增酒店商户
     */
    @ApiOperation("新增酒店商户")
    @RequiresPermissions("shop:hotel:add")
    @Log(title = "酒店商户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopHotel shopHotel)
    {
        return success(shopHotelService.insertShopHotel(shopHotel));
    }

    /**
     * 修改酒店商户
     */
    @ApiOperation("修改酒店商户")
    @RequiresPermissions("shop:hotel:edit")
    @Log(title = "酒店商户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopHotel shopHotel)
    {
        return toAjax(shopHotelService.updateShopHotel(shopHotel));
    }

    /**
     * 删除酒店商户
     */
    @ApiOperation("删除酒店商户")
    @RequiresPermissions("shop:hotel:remove")
    @Log(title = "酒店商户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopHotelService.deleteShopHotelByIds(ids));
    }
}
